@echo off
REM ============================================================
REM Qt 检测脚本示例
REM 此脚本用于自动检测 Qt 安装路径并设置相关环境变量
REM ============================================================

echo Detecting Qt installation...

REM 方式 1: 直接指定已知的 Qt 路径
if exist "D:\Qt\5.15.2\msvc2019_64" (
    set QTDIR=D:\Qt\5.15.2\msvc2019_64
    echo Found Qt at: %QTDIR%
    goto :found
)

REM 方式 2: 尝试从常见位置检测
if exist "C:\Qt\5.15.2\msvc2019_64" (
    set QTDIR=C:\Qt\5.15.2\msvc2019_64
    echo Found Qt at: %QTDIR%
    goto :found
)

if exist "C:\Qt\5.12.5\msvc2017_64" (
    set QTDIR=C:\Qt\5.12.5\msvc2017_64
    echo Found Qt at: %QTDIR%
    goto :found
)

REM 方式 3: 从系统环境变量读取（如果已设置）
if defined QTDIR (
    echo Using existing QTDIR: %QTDIR%
    goto :found
)

echo WARNING: Qt installation not found!
echo Please set QTDIR manually in your configuration file.
exit /b 1

:found
REM 设置 Qt 相关的其他环境变量
set Qt5_DIR=%QTDIR%\lib\cmake\Qt5
set QT_PLUGIN_PATH=%QTDIR%\plugins
set QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms

echo Qt environment variables configured successfully!
exit /b 0
